package oakclub.service;

import oakclub.global.Config;
import oakclub.utility.EncryptUtility;

import java.io.File;

public class VideoService
{
    private final String mediaDir = Config.get("media.dir");
    private final String videoUrl = Config.get("media.url.video");

    private String getAbsolutePath(String path)
    {
        if(path == null)
        {
            path = "";
        }
        return this.mediaDir + '/' + path;
    }

    public String getUrl(String path)
    {
        // video not exist
        String absolutePath = this.getAbsolutePath(path);
        File file = new File(absolutePath);
        if(!file.exists() || !file.isFile())
        {
            return "";
        }

        return EncryptUtility.base64Encode(path);
    }
}
